import Default from '../layouts/default/Default'
import { exceptionRoutesName } from '../env'
import authority from '../core/authority-config'

const routes = [
  {
    path: '/',
    name: 'Default',
    component: Default,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/Dashboard'),
        meta: {
          title: '控制面板',
          icon: 'el-icon-monitor'
        }
      }
    ]
  },
  {
    path: '/feedback',
    name: 'Feedback',
    component: Default,
    redirect: { name: 'UserFeedback' },
    children: [
      {
        path: 'user',
        name: 'UserFeedback',
        component: () => import('@/views/feedback/user/UserFeedback'),
        meta: {
          title: '反馈信息',
          icon: 'el-icon-edit-outline',
          slug: 'F',
          permission: authority.feedback.menu
        }
      }
    ]
  },
  {
    path: '/business',
    name: 'Business',
    component: Default,
    redirect: { name: 'SupplierMaintenance' },
    meta: {
      title: '业务配置',
      icon: 'el-icon-receiving'
    },
    children: [
      {
        path: 'maintenance-supplier',
        name: 'SupplierMaintenance',
        component: () => import('@/views/business/maintenance-supplier/SupplierMaintenance'),
        meta: {
          title: '维保供应商',
          slug: 'M',
          permission: authority.business.maintenanceSupplier.menu
        }
      },
      {
        path: 'maintenance-category',
        name: 'MaintenanceCategory',
        component: () => import('@/views/business/maintenance-category/MaintenanceCategory'),
        meta: {
          title: '维保商品分类',
          slug: 'M',
          permission: authority.business.maintenanceCategory.menu
        }
      }, {
        path: 'maintenance-goods',
        name: 'MaintenanceGoods',
        component: () => import('@/views/business/maintenance-goods/MaintenanceGoods'),
        meta: {
          title: '维保商品',
          slug: 'M',
          permission: authority.business.maintenanceGoods.menu
        }
      },
      {
        path: 'fresh-supplier',
        name: 'FreshSupplier',
        component: () => import('@/views/business/fresh-supplier/SupplierFresh'),
        meta: {
          title: '生鲜供应商',
          slug: 'F',
          permission: authority.business.freshSupplier.menu
        }
      },
      {
        path: 'fresh-category',
        name: 'FreshCategory',
        component: () => import('@/views/business/fresh-category/FreshCategory'),
        meta: {
          title: '生鲜商品分类',
          slug: 'F',
          permission: authority.business.freshCategory.menu
        }
      },
      {
        path: 'fresh-goods',
        name: 'FreshGoods',
        component: () => import('@/views/business/fresh-goods/FreshGoods'),
        meta: {
          title: '生鲜商品',
          slug: 'F',
          permission: authority.business.freshGoods.menu
        }
      },
      {
        path: 'commander',
        name: 'Commander',
        component: () => import('@/views/business/commander/Commander'),
        meta: {
          title: '团长信息',
          slug: 'C',
          permission: authority.business.commander.menu
        }
      },
      {
        path: 'community-info',
        name: 'CommunityInfo',
        component: () => import('@/views/business/community-info/CommunityInfo'),
        meta: {
          title: '社区信息',
          slug: 'C',
          permission: authority.business.communityInfo.menu
        }
      },
      {
        path: 'banners',
        name: 'Banners',
        component: () => import('@/views/business/banners/Banners'),
        meta: {
          title: 'banner配置',
          slug: 'B',
          permission: authority.business.banners.menu
        }
      }
    ]
  },
  {
    path: '/orders',
    name: 'Orders',
    component: Default,
    redirect: { name: 'MaintenanceSupplierOrder' },
    meta: {
      title: '订单管理',
      icon: 'el-icon-s-order'
    },
    children: [
      {
        path: 'maintenance-supplier',
        name: 'MaintenanceSupplierOrder',
        component: () => import('@/views/orders/maintenance-supplier/MaintenanceSupplier'),
        meta: {
          title: '维保订单',
          slug: 'M',
          permission: authority.orders.maintenanceSupplier.menu
        }
      },
      {
        path: 'maintenance-manage',
        name: 'MaintenanceManageOrder',
        component: () => import('@/views/orders/maintenance-manage/MaintenanceManage'),
        meta: {
          title: '维保运营者订单',
          slug: 'M',
          permission: authority.orders.maintenanceManage.menu
        }
      },
      {
        path: 'fresh-supplier',
        name: 'FreshSupplierOrder',
        component: () => import('@/views/orders/fresh-supplier/FreshSupplier'),
        meta: {
          title: '生鲜供应商订单',
          slug: 'F',
          permission: authority.orders.freshSupplier.menu
        }
      },
      {
        path: 'fresh-supplier-sales-c',
        name: 'FreshSupplierSalesC',
        component: () => import('@/views/orders/fresh-supplier-sales-c/FreshSupplierSalesC'),
        meta: {
          title: '生鲜供应商销量单(团长)',
          slug: 'F',
          permission: authority.orders.freshSupplierSalesCommander.menu
        }
      },
      {
        path: 'fresh-supplier-sales',
        name: 'FreshSupplierSales',
        component: () => import('@/views/orders/fresh-supplier-sales/FreshSupplierSales'),
        meta: {
          title: '生鲜供应商销量单',
          slug: 'F',
          permission: authority.orders.freshSupplierSales.menu

        }
      },
      {
        path: 'fresh-manage',
        name: 'FreshManageOrder',
        component: () => import('@/views/orders/fresh-manage/FreshManage'),
        meta: {
          title: '生鲜运营者订单',
          slug: 'F',
          permission: authority.orders.freshManage.menu
        }
      },
      {
        path: 'fresh-manage-sales-c',
        name: 'FreshManageSalesC',
        component: () => import('@/views/orders/fresh-manage-sales-c/FreshManageSalesC'),
        meta: {
          title: '生鲜销量单(团长)',
          slug: 'F',
          permission: authority.orders.freshManageSalesCommander.menu

        }
      },
      {
        path: 'fresh-manage-sales',
        name: 'FreshManageSales',
        component: () => import('@/views/orders/fresh-manage-sales/FreshManageSales'),
        meta: {
          title: '生鲜销量单',
          slug: 'F',
          permission: authority.orders.freshManageSales.menu
        }
      }
    ]
  },
  {
    path: '/product-operation',
    name: 'ProductOperation',
    component: Default,
    redirect: { name: 'DiscountCoupon' },
    meta: {
      title: '产品运营',
      icon: 'el-icon-shopping-cart-full'
    },
    children: [
      {
        path: 'discount-coupon',
        name: 'DiscountCoupon',
        component: () => import('@/views/product-operation/discount-coupon/DiscountCoupon'),
        meta: {
          title: '优惠券',
          slug: 'D',
          permission: authority.productOperation.discountCoupon.menu
        }
      },
      {
        path: 'recharge',
        name: 'Recharge',
        component: () => import('@/views/product-operation/recharge/Recharge'),
        meta: {
          title: '充值活动',
          slug: 'R',
          permission: authority.productOperation.recharge.menu
        }
      }
    ]
  },
  {
    path: '/system',
    name: 'System',
    component: Default,
    redirect: { name: 'Account' },
    meta: {
      title: '系统设置',
      icon: 'el-icon-menu'
    },
    children: [
      {
        path: 'account',
        name: 'Account',
        component: () => import('@/views/system/account/Account'),
        meta: {
          title: '账号管理',
          slug: 'A',
          permission: authority.system.account.menu
        }
      },
      {
        path: 'role',
        name: 'Role',
        component: () => import('@/views/system/role/Role'),
        meta: {
          title: '角色管理',
          slug: 'R',
          permission: authority.system.role.menu
        }
      },
      {
        path: 'config',
        name: 'Config',
        component: () => import('@/views/system/config/Config'),
        meta: {
          title: '系统配置',
          slug: 'C',
          permission: authority.system.config.menu
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/Login'),
    meta: {
      hideInMenu: true
    }
  },
  {
    path: '/exception',
    component: Default,
    meta: { hideInMenu: true },
    children: [
      {
        path: '404',
        name: exceptionRoutesName.NotFound,
        component: () => import('@/views/exception/404'),
        meta: {
          hideInMenu: true,
          hideInNav: true
        }
      },
      {
        path: '401',
        name: exceptionRoutesName.NoAuth,
        component: () => import('@/views/exception/401'),
        meta: {
          hideInMenu: true,
          hideInNav: true
        }
      }
    ]
  },
  {
    path: '*',
    redirect: { name: exceptionRoutesName.NotFound },
    meta: {
      hideInMenu: true
    }
  }
]

export default routes
